#!/bin/bash
if [ "$1" = "config" ]; then
        echo "graph_order lowprio lambda email toip ssh worksrv vip skype"
        echo "graph_title QoS Down traffic"
        echo 'graph_args --base 1000'
        echo 'graph_vlabel bits per second'
	echo 'graph_category qos'
        echo 'graph_info Repartition QoS en traffic descendant'

        echo 'lowprio.label Tres basse prio'
        echo 'lowprio.draw AREA'
        echo 'lowprio.type DERIVE'
        echo 'lowprio.colour c4c4c4'
        echo 'lowprio.min 0'

        echo 'lambda.label Traffic de tous'
        echo 'lambda.draw STACK'
        echo 'lambda.type DERIVE'
        echo 'lambda.colour bbe791'
        echo 'lambda.min 0'

        echo 'email.label Email'
        echo 'email.draw STACK'
        echo 'email.type DERIVE'
        echo 'email.min 0'

        echo 'toip.label TOIP'
        echo 'toip.draw STACK'
        echo 'toip.type DERIVE'
        echo 'toip.colour 000000'
        echo 'toip.min 0'

        echo 'ssh.label SSH'
        echo 'ssh.draw STACK'
        echo 'ssh.type DERIVE'
        echo 'ssh.colour ff0000'
        echo 'ssh.min 0'
  
        echo 'worksrv.label SRV et VPN'
        echo 'worksrv.draw STACK'
        echo 'worksrv.type DERIVE'
        echo 'worksrv.min 0'

        echo 'vip.label VIP'
        echo 'vip.draw STACK'
        echo 'vip.type DERIVE'
        echo 'vip.colour 05910b'
        echo 'vip.min 0'

        echo 'skype.label Skype'
        echo 'skype.draw STACK'
        echo 'skype.type DERIVE'
       	echo 'skype.colour 6699cc'
        echo 'skype.min 0'

        exit 0
fi;


echo "lowprio.value " $(tc -s -d class show dev eth0     | grep -A 2 ':80'     | awk '/^ Sent/ {print $2*8}')
echo "lambda.value "  $(tc -s -d class show dev eth0     | grep -A 2 '1:a0'    | awk '/^ Sent/ {total=total+$2} END{print total*8}')
echo "email.value "   $(tc -s -d class show dev eth0     | grep -A 2 ':60'     | awk '/^ Sent/ {print $2*8}')
echo "ssh.value "     $(tc -s -d class show dev eth0     | grep -A 2 ':50'     | awk '/^ Sent/ {print $2*8}')
echo "toip.value "    $(tc -s -d class show dev eth0     | grep -A 2 ':40'     | awk '/^ Sent/ {print $2*8}')
echo "worksrv.value " $(tc -s -d class show dev eth0     | grep -A 2 ':30'     | awk '/^ Sent/ {print $2*8}')
echo "vip.value "     $(tc -s -d class show dev eth0     | grep -A 2 ':20'     | awk '/^ Sent/ {print $2*8}')
echo "skype.value "   $(tc -s -d class show dev eth0     | grep -A 2 ':10'     | awk '/^ Sent/ {print $2*8}')


